/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-03-18
 * Time: 10:11
 */

public class TestData {
    public int year;
    public int month;
    public int day;

    public TestData(){      //无参构造方法，不带参数的构造方法，如果有其他的构造方法，那么这个就不会被自动生成。
        this.year = 1998;    //如果代码中没有任何构造方法，编译器会自动生成一个无参的构造方法。
        this.month = 1;
        this.day = 22;
        System.out.println("无参的构造方法！");
    }

/*    public TestData(int year, int month, int day){   //有参构造方法
        this.year = year;
        this.month = month;
        this.day = day;
        System.out.println("调用带参数的构造方法!");
    }*/

    public TestData(int year, int month, int day) {    //鼠标右键Generate然后点Constructor,随后可以按住shift进行多选。
        this.year = year;                              //编译器自动帮助生成带参构造方法。
        this.month = month;
        this.day = day;
    }

    /*    public void setData(int year, int month, int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }*/

    public void printData(){
        System.out.println("year: " + this.year + " month: " + this.month + " day: " + this.day);
    }

    public static void main(String[] args) {
        TestData d1 = new TestData(1949,6,1);
        TestData d2 = new TestData(1978,3,12);
        TestData d3 = new TestData();


/*      d1.setData(2022, 3, 14);
        d2.setData(1998, 1, 13);
        d3.setData(1949, 2, 12);*/

        d1.printData();
        d2.printData();
        d3.printData();


    }
}
